<template>
  <rx-dialog @handOk="handleOk" :oktext="$ti18('rxForm.closeBtn','关闭')" :showcancel="false" btnalign="right" order="top">
    <a-tabs defaultActiveKey="jsonView">
      <a-tab-pane :tab="i18n('list.jsonView','JSON视图')" key="jsonView">
        <json-viewer
          :value="jsonView"
          :expand-depth="5"
          copyable
          boxed
          sort
        ></json-viewer>
      </a-tab-pane>
      <a-tab-pane :tab="i18n('list.jsonData','JSON数据')" key="jsonData">
        <a-textarea v-model="jsonData"></a-textarea>
      </a-tab-pane>
    </a-tabs>
  </rx-dialog>
</template>
<script>
  import FormBoDefApi from '@/api/form/bo/formBoDef'
  import {Util} from "@lowcode/jpaas-common-lib"
  export default {
    name: 'FormBoDefJson',
    props:["pkId","layerid","destroy"],
    data(){
      return {
        jsonView:{},
        jsonData:""
      }
    },
    created() {
      this.getJson();
    },
    methods: {
      i18n(name,text,key){
          return this.$ti18(name,text,"formBoDef",key);
      },
      handleOk(){
        Util.closeWindow(this,"ok");
      },
      getJson(){
        FormBoDefApi.getJsonData(this.pkId).then(res=>{
          var data=res.data;
          this.jsonView=data;
          this.jsonData=JSON.stringify(data);
        })
      }
    }
  }
</script>
